#version 330

layout(location = 0) in vec4 vertex;
layout(location = 1) in vec4 normal;
layout(location = 2) in vec2 uv;

uniform mat4 perspectiveMatrix;
uniform float angle;
uniform vec3 camera;
uniform vec4 position;

out VertexData{
    vec4 normal;
    vec2 texCoord;
} vertexOut;

void main()
{
    mat4 zRotationMatrix = mat4(1.0f);
    zRotationMatrix[1].y = cos(angle);
    zRotationMatrix[1].z =-sin(angle);
    zRotationMatrix[2].y = sin(angle);
    zRotationMatrix[2].z = cos(angle);

    vec4 cameraPos = vertex + position + vec4( camera, 0.0f);

    gl_Position = perspectiveMatrix * zRotationMatrix *  cameraPos;

    vertexOut.normal = normal;
    vertexOut.texCoord = uv;
}
